# 程序员鼓励师
import random

from pynput import keyboard
from playsound import playsound
from threading import Thread

count = 0
soundList = ['sound/1.mp3', 'sound/2.mp3', 'sound/3.mp3', 'sound/4.mp3']

def onRelease(key):
    print(key)
    global count
    count += 1
    if count % 10 == 0:
        # 播放音乐
        # playsound('sound/1.mp3')
        i = random.randint(0, len(soundList) - 1)
        # playsound(soundList[i])
        t = Thread(target=playsound, args=(soundList[i], ))
        t.start()


# 监视松开按键
listener = keyboard.Listener(on_release=onRelease)
listener.start()
listener.join()


